//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.farm.doc.dao.impl;

import com.farm.core.sql.query.DBRule;
import com.farm.core.sql.query.DataQuery;
import com.farm.core.sql.result.DataResult;
import com.farm.core.sql.utils.HibernateSQLTools;
import com.farm.doc.dao.DocfiletextDaoInter;
import com.farm.doc.domain.Docfiletext;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

@Repository
public class DocfiletextDaoImpl extends HibernateSQLTools<Docfiletext> implements DocfiletextDaoInter {
	@Resource(name = "sessionFactory")
	private SessionFactory sessionFatory;

	public DocfiletextDaoImpl() {
	}

	public void deleteEntity(Docfiletext docfiletext) {
		Session session = this.sessionFatory.getCurrentSession();
		session.delete(docfiletext);
	}

	public int getAllListNum() {
		Session session = this.sessionFatory.getCurrentSession();
		SQLQuery sqlquery = session.createSQLQuery("select count(*) from farm_code_field");
		BigInteger num = (BigInteger) sqlquery.list().get(0);
		return num.intValue();
	}

	public Docfiletext getEntity(String docfiletextid) {
		Session session = this.sessionFatory.getCurrentSession();
		return (Docfiletext) session.get(Docfiletext.class, docfiletextid);
	}

	public Docfiletext insertEntity(Docfiletext docfiletext) {
		Session session = this.sessionFatory.getCurrentSession();
		session.save(docfiletext);
		return docfiletext;
	}

	public void editEntity(Docfiletext docfiletext) {
		Session session = this.sessionFatory.getCurrentSession();
		session.update(docfiletext);
	}

	public Session getSession() {
		return this.sessionFatory.getCurrentSession();
	}

	public DataResult runSqlQuery(DataQuery query) {
		try {
			return query.search(this.sessionFatory.getCurrentSession());
		} catch (Exception var3) {
			return null;
		}
	}

	public void deleteEntitys(List<DBRule> rules) {
		this.deleteSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
	}

	public List<Docfiletext> selectEntitys(List<DBRule> rules) {
		return this.selectSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
	}

	public void updataEntitys(Map<String, Object> values, List<DBRule> rules) {
		this.updataSqlFromFunction(this.sessionFatory.getCurrentSession(), values, rules);
	}

	public int countEntitys(List<DBRule> rules) {
		return this.countSqlFromFunction(this.sessionFatory.getCurrentSession(), rules);
	}

	public SessionFactory getSessionFatory() {
		return this.sessionFatory;
	}

	public void setSessionFatory(SessionFactory sessionFatory) {
		this.sessionFatory = sessionFatory;
	}

	protected Class<?> getTypeClass() {
		return Docfiletext.class;
	}

	protected SessionFactory getSessionFactory() {
		return this.sessionFatory;
	}
}
